import axios from 'axios'

export function request(config) {
  return new Promise((resolve, reject) => {
    const instance = axios.create({
      baseURL: 'http://123.207.32.32:9001',
      timeout:  10000
    })

    instance.interceptors.request.use(config => {
      return config
    })

    instance.interceptors.response.use(res => {
      return res.data
    })

    instance(config).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

export function request2(config) {
  return new Promise((resolve, reject) => {
    const instance = axios.create({
      baseURL: 'http://localhost:3000',
      timeout:  10000
    })

    instance.interceptors.request.use(config => {
      return config
    })

    instance.interceptors.response.use(res => {
      return res.data
    })

    instance(config).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

